
#define APPNAME "zk"


#define CMD_SERVER_SHAKE		0xDE	// 握手	 内容为  "SHAKE2014TOBONEY"	  接收方回复 "SHAKE2014OKBONEY"
#define CMD_SERVER_GPASS		0xDD	// 认证	 内容为　16bytes固定key[发送方已变换过，接收方解秘后还需要还原后使用] 接收方回复 "GPASS2014OKBONEY"
#define CMD_SERVER_HEART		0xDA	// 心跳	 内容为　"HELLO2014TOBONEY"	  接收方回复 "HELLO2014OKBONEY"

#define ID_FOR_ZK               0xDD    //中控机器
#define ID_FOR_SERVER           0xAA    //服务器
#define ID_FOR_MOBILE           0xCC    //移动设备

#define INT_FOR_ZK              0    //中控机器
#define INT_FOR_SERVER          1    //服务器
#define INT_FOR_MOBILE          2    //移动设备


unsigned short crc16_Verify(unsigned char * pData, int nLength);

unsigned short ZK_getcrc(char* data_buf, long len);

void ZK_getSendBytes (unsigned char* datain, int lenin, unsigned char* dataout,int *lenout);


void packdata(unsigned char * pdata, int plength);
int unpackdata(unsigned char * pdata);

void ZK_encrypt(unsigned char* dataE, int lenE, int *outlenE, unsigned char* key);


void ZK_decrypt(unsigned char* dataD, int lenD, int *outlenD, unsigned char* key);


void ZK_getkey(unsigned char* data,int len,unsigned char* getkey);


void ZK_setkey(unsigned char* data,int len,unsigned char* setkey);

int GetDKey(unsigned char *pData, int DataLen, unsigned char* damKey, int switchType);

int ReGetKey(unsigned char *pData, int DataLen, unsigned char* damKey);



